<template>
	<view class="orderDetail">
		<view v-if="pageData.status == 1" class="statusBox">
			<image src="../../static/image/after1.png" style="width: 80rpx;height: 80rpx;" mode=""></image>
			<view class="rightMessage">
				<view class="text">
					已退款，金额：₱{{pageData.all_price}}
				</view>
				<view class="bottom">
					申请时间：{{pageData.created_at}}
				</view>
			</view>
		</view>
		<view v-if="pageData.status == 0" class="statusBox">
			<image src="../../static/image/after2.png" style="width: 80rpx;height: 80rpx;" mode=""></image>
			<view class="rightMessage">
				<view class="text">
					审核中
				</view>
				<view class="bottom">
					申请时间：{{pageData.created_at}}
				</view>
			</view>
		</view>
		<view v-if="pageData.status == 2" class="statusBox">
			<image src="../../static/image/after3.png" style="width: 80rpx;height: 80rpx;" mode=""></image>
			<view class="rightMessage">
				<view class="text">
					退款失败
				</view>
				<view class="bottom">
					申请时间：{{pageData.created_at}}
				</view>
			</view>
		</view>

		<!-- 地址 -->
		<view class="addressBox">

			售后信息
		</view>

		<view class="productMessage">
			<view class="number">
				共计1件商品
			</view>

			<view class="detailBox">
				<image :src="pageData.products_image" style="width: 160rpx;height: 160rpx;" mode="">
				</image>
				<view class="message">
					<view class="name">
						{{pageData.products_name}}
					</view>
					<view class="desc">
						规格：{{pageData.sku_text}}
					</view>
					<view class="bottom">
						<view class="price">
							₱{{pageData.price}}
						</view>
						<view class="number">
							x{{pageData.num}}
						</view>
					</view>
				</view>
			</view>


		</view>

		<view class="ordermessage">

			<view class="messageItem">
				<view class="lable">
					订单编号：
				</view>
				<view class="value">
					<text class="copy">复制</text>
					<text class="">
						{{pageData.order_no}}
					</text>
				</view>
			</view>
			<view class="messageItem">
				<view class="lable">
					退款金额：
				</view>
				<view class="value">
					<view class="">
						₱{{pageData.all_price}}
					</view>
				</view>
			</view>
			<view class="messageItem">
				<view class="lable">
					售后方式：
				</view>
				<view class="value">
					<view class="">
						仅退款
					</view>
				</view>
			</view>
			<view class="messageItem">
				<view class="lable">
					申请件数：
				</view>
				<view class="value">
					<view class="">
						{{pageData.num}}
					</view>
				</view>
			</view>
			<view class="messageItem">
				<view class="lable">
					申请时间：
				</view>
				<view class="value">
					<view class="">
						{{pageData.created_at}}
					</view>
				</view>
			</view>
			<view class="messageItem">
				<view class="lable">
					备注说明：
				</view>
				<view class="value">
					<view class="">
						{{pageData.back_remark}}
					</view>
				</view>
			</view>
			<view class="messageItem">
				<view class="lable">
					售后凭证：
				</view>
				<view class="value">
					<view class="">
						无
					</view>
				</view>
			</view>


		</view>


		<view class="actualPay">
			<view class="lable">
				应退款：
			</view>
			<view class="value">
				₱{{pageData.all_price}}
			</view>
		</view>

		<view class="" style="height: 150rpx;"></view>

		<view v-if="pageData.status == 0" class="btnBox">
			<view class="btn" @click="delshow = true">
				撤销申请
			</view>
		</view>

		<u-modal :show="delshow" :title="title" :showCancelButton="true" @confirm="handledelbacksales"
			@cancel="delshow = false" confirmColor="#439B05"></u-modal>

	</view>
</template>

<script>
	import {
		backordersdetail,
		delbacksales
	} from "@/api/api.js"
	export default {
		data() {
			return {
				pageId: "",
				pageData: {},
				title: "确定要撤销售后吗?",
				delshow: false,
			}
		},
		onLoad(options) {
			this.pageId = options.id
			this.handlebackordersdetail()
		},
		methods: {
			async handlebackordersdetail() {
				let res = await backordersdetail({
					order_id: this.pageId
				})
				this.pageData = res.data
			},
			async handledelbacksales() {
				let res = await delbacksales({
					id: this.pageData.order_id
				})
				if (res.code == 1000) {
					this.delshow = false
					uni.showToast({
						title: res.message,
						icon: "none",
						duration: 2000
					});
					setTimeout(() => {
						uni.navigateBack({
							delta: 1
						})
					}, 2000)
				} else {
					this.delshow = false
					uni.showToast({
						title: res.message,
						icon: "none",
						duration: 2000
					});
				}
			},
			handleApplyfor() {
				uni.navigateTo({
					url: "./applyFor"
				})
			},

		}
	}
</script>

<style scoped lang="scss">
	.orderbtnBox {
		display: flex;
		background-color: #ffffff;

		.orderbtn {
			width: 160rpx;
			height: 64rpx;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			opacity: 1;
			border: 2rpx solid #CCCCCC;
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			color: #333333;
			line-height: 64rpx;
			text-align: center;
			border-radius: 100rpx;
		}
	}

	.btnBox {
		width: 100%;
		padding: 20rpx;
		box-sizing: border-box;
		background-color: #ffffff;
		position: fixed;
		bottom: 0;

		.btn {
			width: 670rpx;
			height: 88rpx;
			background: #439B05;
			border-radius: 200rpx 200rpx 200rpx 200rpx;
			font-size: 32rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 88rpx;
			text-align: center;
			margin-left: 30rpx;
		}
	}

	.orderDetail {
		.statusBox {
			width: 100%;
			height: 160rpx;
			background: #439B05;
			padding: 40rpx 30rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;

			.rightMessage {
				margin-left: 20rpx;

				.text {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 33rpx;
				}

				.bottom {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 28rpx;
					margin-top: 6rpx;
				}
			}
		}

		.addressBox {
			width: 100%;
			background: #FFFFFF;
			padding: 30rpx;
			box-sizing: border-box;
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			color: #333333;
			line-height: 33rpx;
		}

		.productMessage {
			width: 100%;
			height: 300rpx;
			background-color: #ffffff;
			padding: 30rpx;
			box-sizing: border-box;
			margin-top: 1rpx;

			.number {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 60rpx;
				border-bottom: 1rpx solid #F5F5F5;
			}

			.detailBox {
				display: flex;
				margin-top: 24rpx;

				.message {
					margin-left: 20rpx;

					.name {
						font-size: 32rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						color: #333333;
						line-height: 38rpx;
						width: 452rpx;
						white-space: nowrap;
						/* 设置不换行 */
						overflow: hidden;
						/* 设置超出部分隐藏 */
						text-overflow: ellipsis;
					}

					.desc {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: #999999;
						line-height: 28rpx;
						margin-top: 20rpx;
					}

					.bottom {
						display: flex;
						width: 100%;
						justify-content: space-between;
						margin-top: 34rpx;

						.price {
							font-size: 32rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							color: #333333;
							line-height: 38rpx;
						}

						.number {
							font-size: 28rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							color: #999999;
							line-height: 33rpx;
						}
					}
				}
			}
		}


		.ordermessage {
			width: 100%;
			background: #FFFFFF;
			padding: 30rpx;
			box-sizing: border-box;
			margin-top: 1rpx;

			.messageItem {
				display: flex;
				justify-content: space-between;
				margin-bottom: 20rpx;


				.lable {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 33rpx;
				}

				.value {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #999999;
					line-height: 33rpx;
				}

				.copy {
					width: 60rpx;
					height: 30rpx;
					border-radius: 30rpx;
					border: 2rpx solid #CCCCCC;
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #999999;
					line-height: 28rpx;
					display: inline-block;
					text-align: center;
					margin-right: 10rpx;
				}
			}
		}


		.actualPay {
			width: 750rpx;
			height: 100rpx;
			background: #FFFFFF;
			padding: 30rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			margin-top: 1rpx;

			.lable {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 33rpx;
			}

			.value {
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #FF3D3D;
				line-height: 38rpx;
			}
		}
	}
</style>